home *** CD-ROM | disk | FTP | other *** search
/ 3D Games (Spidla) / 3dhry2.iso / Sokoban 3D Deluxe 1.0 / sokoban-intro.bb < prev    next >
Encoding:
Text File  |  2003-03-17  |  16.9 KB  |  463 lines

  1. ; Sokoban Final
  2. ; By Reda Borchardt
  3.  
  4. ; Variables
  5.     Global ScreenHeight
  6.     Global ScreenWidth
  7.     Global Sokoban
  8.     Global FontImg
  9.     Global DnaBannerImg
  10.     Global DnaBanner2Img
  11.     Global DnaBanner3Img
  12.     Global BottomImg
  13.     Global This_Level_Number = 1
  14.     Global Current_Move
  15.     Global Level_Pivot
  16.     Global CurrentZoom#=1
  17.     Global Camera
  18.     Global CameraPivot
  19.     Global CameraPivot2
  20.     Global NewLevel
  21.     Dim LEVEL_TEMPLATE$(500,21,21)
  22.     Dim CURRENT_LEVEL$(3000,21,21)
  23.  
  24. ; Initialization 
  25.     Include "start.bb"
  26.     Include "keyconstants.bb"
  27.     SetBuffer BackBuffer()
  28.     SetFont LoadFont("Arial",14,1,0,1)
  29.     FontImg = LoadAnimImage("font.bmp",18,16,0,49)
  30.     DnaBannerImg = LoadImage("top-banner.jpg")
  31.     DnaBanner2Img = LoadImage("bottom-banner.jpg")
  32.     DnaBanner3Img = LoadImage("side-banner.jpg")
  33.     LoadLevelData("Levels.dat")
  34.     
  35. ; Display First Level
  36. For y = 1 To 21
  37.     For z = 1 To 21
  38.         CURRENT_LEVEL$(CURRENT_MOVE,y,z) = LEVEL_TEMPLATE$(This_Level_Number,y,z)
  39.     Next
  40. Next
  41. DisplayLevel3D(CURRENT_MOVE)
  42.     
  43.     ;This is in case the Window mode is enabled.
  44.     If ScreenHeight = 0
  45.         ScreenHeight = 480
  46.         ScreenWidth = 640
  47.     End If
  48.     
  49. ; Setup Scene
  50.     CameraPivot2 = CreatePivot()
  51.     CameraPivot = CreatePivot(CameraPivot2)
  52.     Camera = CreateCamera(CameraPivot)
  53.     CameraViewport Camera,4,60,ScreenWidth-148,ScreenHeight-128
  54.     PositionEntity Camera,0,32,0
  55.     TurnEntity camera,90,0,0
  56.     AmbientLight(255,255,255)
  57.     
  58.     sphere = CreateSphere(5)
  59.     nebula = LoadTexture("nebula.jpg")
  60.     ScaleEntity sphere,50,50,50
  61.     FlipMesh sphere
  62.     TurnEntity Sphere,180,0,90
  63.     RotateTexture nebula,180
  64.     EntityTexture sphere,nebula
  65.     TextureCoords nebula,0
  66.  
  67.  
  68. ; Main Loop
  69. While Not KeyHit(1)
  70.     KeyBoardEvents()
  71.  
  72.     UpdateWorld
  73.     RenderWorld
  74.     
  75.     ; This is the 2D Stuff after the 3D scene has been updated
  76.     BuildTheGui()
  77.     
  78.     Flip
  79.     
  80. Wend
  81. End
  82.  
  83. ;Functions
  84. Function BuildTheGui()
  85.     ;Draw The Top Banner
  86.         DrawBlock DnaBannerImg,0,0
  87.         
  88.     ;Draw The Bottom Banner
  89.         DrawBlock DnaBanner2Img,0,ScreenHeight-60
  90.         
  91.     ;Draw The Side Banner
  92.         DrawBlock DnaBanner3Img,ScreenWidth-140,60
  93.         
  94.     ;Draw Level Number
  95.         DrawString(30,445,"LEVEL: " + This_Level_number)
  96.         DrawString(480,445,"MOVES: " + Current_Move)
  97.         
  98.     ;Check Whether Level Is Completed
  99.         If LevelStatsBoxes(ThisLevelNumber) = LevelStatsBoxesOnGoals(ThisLevelNumber)
  100.                     DrawString(30,240,"CONGRATULATIONS!")
  101.         End If
  102.         
  103. End Function
  104.  
  105. Function DrawString(MsgX,MsgY,Message$)
  106. MsgCount = Len(Message$)
  107.  
  108. For F = 0 To (MsgCount - 1)
  109.     FontChar = Asc(Lower$(Mid$(Message$,F + 1,1)))
  110.  
  111.     Select FontChar
  112.     ; Letters
  113.     Case 97 : ImgChar = 0 : Case 98 : ImgChar = 1 : Case 99 : ImgChar = 2
  114.     Case 100 : ImgChar = 3 : Case 101 : ImgChar = 4 : Case 102 : ImgChar = 5
  115.     Case 103 : ImgChar = 6 : Case 104 : ImgChar = 7 : Case 105 : ImgChar = 8
  116.     Case 106 : ImgChar = 9 : Case 107 : ImgChar = 10 : Case 108 : ImgChar = 11
  117.     Case 109 : ImgChar = 12 : Case 110 : ImgChar = 13 : Case 111 : ImgChar = 14
  118.     Case 112 : ImgChar = 15 : Case 113 : ImgChar = 16 : Case 114 : ImgChar = 17
  119.     Case 115 : ImgChar = 18 : Case 116 : ImgChar = 19 : Case 117 : ImgChar = 20
  120.     Case 118 : ImgChar = 21 : Case 119 : ImgChar = 22 : Case 120 : ImgChar = 23
  121.     Case 121 : ImgChar = 24 : Case 122 : ImgChar = 25
  122.  
  123.     ; Numbers
  124.     Case 48 : ImgChar = 26 : Case 49 : ImgChar = 27 : Case 50 : ImgChar = 28
  125.     Case 51 : ImgChar = 29 : Case 52 : ImgChar = 30 : Case 53 : ImgChar = 31
  126.     Case 54 : ImgChar = 32 : Case 55 : ImgChar = 33 : Case 56 : ImgChar = 34
  127.     Case 57 : ImgChar = 35
  128.  
  129.     ; Special characters
  130.     Case 63 : ImgChar = 36 : Case 46 : ImgChar = 37 : Case 44 : ImgChar = 38
  131.     Case 39 : ImgChar = 39 : Case 34 : ImgChar = 40 : Case 33 : ImgChar = 41
  132.     Case 40 : ImgChar = 42 : Case 41 : ImgChar = 43 : Case 45 : ImgChar = 44
  133.     Case 58 : ImgChar = 45 : Case 59 : ImgChar = 46 : Case 32 : ImgChar = 48
  134.     End Select
  135.  
  136.     DrawImage FontImg,(F * 15) + MsgX,MsgY,ImgChar
  137. Next
  138. End Function
  139.  
  140. Function LoadLevelData$(filename$)
  141.     filein = ReadFile(filename$)
  142.     starttheloop = False
  143.     
  144.     While Not Eof(filein)
  145.         If Left$(rawline$,1)<> ">" Then rawline$ = ReadLine$(filein)
  146.         If Left$(rawline$,1)= ">"
  147.             starttheloop = True ;Detects the start of a level
  148.                currentlevel = currentlevel + 1 ;Counts the level
  149.             currentrow = 0
  150.         End If
  151.  
  152.         If starttheloop = True And Left$(rawline$,1)=">"
  153.         rawline$ = ReadLine$(filein)
  154.             While Left$(rawline$,1) <> ">"
  155.                 currentrow = currentrow + 1
  156.                 For i=1 To Len(rawline$)
  157.                         LEVEL_TEMPLATE$(currentlevel,currentrow,i)= Mid$(rawline$,i,1)
  158.                  Next
  159.                 rawline$ = ReadLine$(filein)
  160.               Wend  
  161.         End If
  162.     Wend
  163.     CloseFile(filein)
  164. End Function
  165.  
  166. Function KeyboardEvents()
  167.     rebuild_level = False
  168.     update_screen = False
  169.     
  170.     If KeyHit(key_numpad_add) Then This_Level_Number = This_Level_Number + 1 : rebuild_level = True : CURRENT_MOVE = 0
  171.     If KeyHit(key_numpad_sub) Then This_Level_Number = This_Level_Number - 1 : rebuild_level = True : CURRENT_MOVE = 0
  172.     
  173.     If this_level_number<1 Then this_level_number = 1
  174.     If this_level_number>375 Then this_level_number = 375
  175.     
  176.     If rebuild_level = True
  177.         For y = 1 To 21
  178.             For z = 1 To 21
  179.                 CURRENT_LEVEL$(CURRENT_MOVE,y,z) = LEVEL_TEMPLATE$(This_Level_Number,y,z)
  180.             Next
  181.         Next
  182.     DisplayLevel3d(CURRENT_MOVE)
  183.     End If
  184.     
  185.     If KeyDown(key_a) 
  186.         CurrentZoom# = CurrentZoom# + 0.01
  187.         CameraZoom Camera,CurrentZoom#
  188.     End If
  189.     
  190.     If KeyDown(key_z) 
  191.         CurrentZoom# = CurrentZoom# - 0.01
  192.         CameraZoom Camera,CurrentZoom#
  193.     End If
  194.     If KeyDown(key_arrowpad_left) And KeyDown(key_leftshift) = True Then TurnEntity CameraPivot2,0,-0.3,0
  195.     If KeyDown(key_arrowpad_right) And KeyDown(key_leftshift) = True Then TurnEntity CameraPivot2,0,0.3,0
  196.     If KeyDown(key_arrowpad_up) And KeyDown(key_leftshift) = True Then TurnEntity CameraPivot,-0.3,0,0
  197.     If KeyDown(key_arrowpad_down) And KeyDown(key_leftshift) = True Then TurnEntity CameraPivot,0.3,0,0
  198.     
  199.     If KeyHit(key_arrowpad_left) And KeyDown(key_leftshift) = False Then MovePlayer("l") : update_screen = True
  200.     If KeyHit(key_arrowpad_right) And KeyDown(key_leftshift) = False Then MovePlayer("r") : update_screen = True
  201.     If KeyHit(key_arrowpad_up) And KeyDown(key_leftshift) = False Then MovePlayer("u") : update_screen = True
  202.     If KeyHit(key_arrowpad_down) And KeyDown(key_leftshift) = False Then MovePlayer("d") : update_screen = True
  203.     If KeyHit(key_backspace) And CURRENT_MOVE <> 0 Then CURRENT_MOVE = CURRENT_MOVE - 1 : update_screen = True
  204.     If update_screen Then DisplayLevel3D(CURRENT_MOVE)        
  205. End Function
  206.  
  207. Function DisplayLevel3D(Move)
  208.     wall_tex = LoadTexture("metal-plate.jpg")
  209.     ground_tex = LoadTexture("ground.jpg")
  210.     box_tex = LoadTexture("metal-plate3.jpg")
  211.     box_tex2 = LoadTexture("metal-plate2.jpg")
  212.     
  213.     If level_pivot Then FreeEntity level_pivot
  214.     level_pivot = CreatePivot()
  215.  
  216.     For y = 1 To 21
  217.         For x = 1 To 21
  218.             If CURRENT_LEVEL$(Move, x, y) = "#"
  219.                 cube = CreateCube(level_pivot)
  220.                 MoveEntity cube, x*2-21, 0, y*2-21
  221.                 EntityTexture cube, wall_tex
  222.             ElseIf CURRENT_LEVEL$(Move,x,y) = "$" Or CURRENT_LEVEL$(Move,x,y) = "*"
  223.                 cube = CreateCube(level_pivot)
  224.                 MoveEntity cube, x*2-21, 0, y*2-21
  225.                 EntityTexture cube, box_tex2
  226.             ElseIf CURRENT_LEVEL$(Move,x,y) = "@" Or CURRENT_LEVEL$(Move,x,y) = "+"
  227.                 sphere = CreateSphere(16,level_pivot)
  228.                 MoveEntity sphere, x*2-21,0,y*2-21
  229.                 EntityColor sphere,255,255,255
  230.             ElseIf CURRENT_LEVEL$(Move,x,y) = "."
  231.                 cube = CreateCube(level_pivot)
  232.                 MoveEntity cube, x*2-21, -2, y*2-21
  233.                 EntityTexture cube, box_tex
  234.  
  235.  
  236.             EndIf        
  237.         Next
  238.     Next
  239. End Function
  240.  
  241.  
  242. Function MovePlayer(direction$)
  243.     For y = 1 To 21
  244.         For x = 1 To 21
  245.             If CURRENT_LEVEL$(CURRENT_MOVE,y,x) = "@" Or CURRENT_LEVEL$(CURRENT_MOVE,y,x) = "+"
  246.                 playerx = y
  247.                 playery = x
  248.             End If
  249.         Next
  250.     Next
  251.     
  252.     For y = 1 To 21
  253.         For x = 1 To 21
  254.             CURRENT_LEVEL$(CURRENT_MOVE+1,y,x) = CURRENT_LEVEL$(CURRENT_MOVE,y,x)
  255.         Next
  256.     Next
  257.     
  258.     MoveBoxes(direction$,playerx,playery)
  259.     
  260.     If direction$ = "l" Then ; Move to the left
  261.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "@"
  262.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "@" ; PUT
  263.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  264.         End If
  265.         
  266.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  267.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "+" ; PUT
  268.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  269.         End If
  270.         
  271.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  272.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "@" ; PUT
  273.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  274.         End If
  275.         
  276.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  277.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "+" ; PUT
  278.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  279.         End If
  280.         
  281.     End If
  282.     
  283.     If direction$ = "r" Then ; Move to the right
  284.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  285.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "@" ; PUT
  286.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  287.         End If
  288.         
  289.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  290.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "+" ; PUT
  291.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  292.         End If
  293.         
  294.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  295.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "@" ; PUT
  296.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  297.         End If
  298.         
  299.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  300.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "+" ; PUT
  301.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  302.         End If
  303.  
  304.     End If
  305.  
  306.     If direction$ = "d" Then ; Move downwards
  307.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  308.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "@" ; PUT
  309.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  310.         End If
  311.         
  312.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  313.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "+" ; PUT
  314.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  315.         End If
  316.         
  317.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  318.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "@" ; PUT
  319.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  320.         End If
  321.         
  322.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  323.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "+" ; PUT
  324.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  325.         End If
  326.  
  327.     End If
  328.     
  329.     If direction$ = "u" Then ; Move upwards
  330.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  331.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "@" ; PUT
  332.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  333.         End If    
  334.         
  335.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "@"
  336.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "+" ; PUT
  337.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = " " ; REMOVE
  338.         End If    
  339.         
  340.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  341.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "@" ; PUT
  342.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  343.         End If    
  344.         
  345.         If CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery) = "+"
  346.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "+" ; PUT
  347.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery) = "." ; REMOVE
  348.         End If
  349.     End If
  350.     CURRENT_MOVE = CURRENT_MOVE + 1
  351.     
  352.     
  353. End Function
  354.  
  355. Function MoveBoxes(direction$,playerx,playery)
  356.     If direction$ = "l" Then ; Move to the left
  357.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx-2,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx-1,playery) = "$"
  358.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-2,playery) = "$" ; PUT
  359.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = " " ; REMOVE
  360.         End If
  361.         
  362.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx-2,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx-1,playery) = "$"
  363.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-2,playery) = "*" ; PUT
  364.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = " " ; REMOVE
  365.         End If
  366.         
  367.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx-2,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx-1,playery) = "*"
  368.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-2,playery) = "$" ; PUT
  369.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "." ; REMOVE
  370.         End If
  371.         
  372.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx-2,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx-1,playery) = "*"
  373.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-2,playery) = "*" ; PUT
  374.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx-1,playery) = "." ; REMOVE
  375.         End If
  376.     End If
  377.     
  378.     If direction$ = "r" Then ; Move to the right
  379.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx+2,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx+1,playery) = "$"
  380.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+2,playery) = "$" ; PUT
  381.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = " " ; REMOVE
  382.         End If
  383.         
  384.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx+2,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx+1,playery) = "$"
  385.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+2,playery) = "*" ; PUT
  386.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = " " ; REMOVE
  387.         End If
  388.         
  389.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx+2,playery) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx+1,playery) = "*"
  390.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+2,playery) = "$" ; PUT
  391.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "." ; REMOVE
  392.         End If
  393.         
  394.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx+2,playery) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx+1,playery) = "*"
  395.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+2,playery) = "*" ; PUT
  396.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx+1,playery) = "." ; REMOVE
  397.         End If
  398.     End If
  399.     
  400.     If direction$ = "u" Then ; Move downwards
  401.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+2) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+1) = "$"
  402.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+2) = "$" ; PUT
  403.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = " " ; REMOVE
  404.         End If
  405.         
  406.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+2) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+1) = "$"
  407.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+2) = "*" ; PUT
  408.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = " " ; REMOVE
  409.         End If
  410.         
  411.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+2) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+1) = "*"
  412.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+2) = "$" ; PUT
  413.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "." ; REMOVE
  414.         End If
  415.         
  416.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+2) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery+1) = "*"
  417.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+2) = "*" ; PUT
  418.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery+1) = "." ; REMOVE
  419.         End If
  420.     End If
  421.     
  422.     If direction$ = "d" Then ; Move downwards
  423.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-2) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-1) = "$"
  424.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-2) = "$" ; PUT
  425.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = " " ; REMOVE
  426.         End If
  427.         
  428.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-2) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-1) = "$"
  429.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-2) = "*" ; PUT
  430.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = " " ; REMOVE
  431.         End If
  432.         
  433.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-2) = " " And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-1) = "*"
  434.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-2) = "$" ; PUT
  435.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "." ; REMOVE
  436.         End If
  437.         
  438.         If CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-2) = "." And CURRENT_LEVEL$(CURRENT_MOVE,playerx,playery-1) = "*"
  439.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-2) = "*" ; PUT
  440.             CURRENT_LEVEL$(CURRENT_MOVE+1,playerx,playery-1) = "." ; REMOVE
  441.         End If
  442.     End If
  443. End Function
  444.  
  445. Function LevelStatsBoxes(LevelNumber)
  446.     For z = 1 To 21
  447.         For y = 1 To 21
  448.             If CURRENT_LEVEL$(CURRENT_MOVE,y,z)="$" Or CURRENT_LEVEL$(CURRENT_MOVE,y,z)="*" Then boxes = boxes + 1        
  449.         Next
  450.     Next
  451.     Return boxes
  452. End Function
  453.  
  454. Function LevelStatsBoxesOnGoals(LevelNumber)
  455.     For z = 1 To 21
  456.         For y = 1 To 21
  457.             If CURRENT_LEVEL$(CURRENT_MOVE,y,z)="*"    Then boxesongoals = boxesongoals + 1    
  458.         Next
  459.     Next
  460.     Return boxesongoals
  461. End Function
  462. Function LevelStatsHeight(LevelNumber)
  463. End Function